package com.person.leetcode.editor.cn;

import java.util.ArrayList;
import java.util.Arrays;

/**
  * 53.最大子数组和
  * 2022-05-25 17:40:02
**/
public class Sequence_0053_MaximumSubarray {
    public static void main(String[] args) {
        Solution solution = new Sequence_0053_MaximumSubarray().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int maxSubArray(int[] nums) {
//            f(i)+arr[i+1],arr[i+1]
            int max = Integer.MIN_VALUE;//最大值
            int fValue = 0;
            for (int n : nums) {
                fValue = Math.max(fValue+n,n);
                max = Math.max(fValue,max);
            }
            return max;
        }
    }


//leetcode submit region end(Prohibit modification and deletion)

}
